/*公共js*/
function popUpImg(imgId,inputId){
	$('div.pop-dailog').remove();
	var html='<div class="pop-dailog" style="display:none;height:'+$(document).height()+'px;">'
		   +'<div class="container">'
		   +'<div class="head">'
		   +'上传图片<div class="buttons"><b class="pop-close" onclick="closeUpImg();"></b></div>'
		   +'</div>'
		   +'<div class="pop-content">'
		   +'<form action="/sys-admin/action/common/upfile.php" method="post" enctype="multipart/form-data" id="up_img">'
		   +'<input type="hidden" name="met" value="upimg"/>'
		   +'<input type="file" name="image" onchange="upImg(\''+imgId+'\',\''+inputId+'\');"/>'
		   +'</form>'
		   +'</div>'
		   +'</div>'
		   +'</div>';
	$('body').append(html);
	var left = ($(document).width()-$('div.pop-dailog').find('div.container').width())/2;
	left = left>0?left:0;
	var top = ($(window).height() - 54)/2;
	top = top>0?top:0;
	top += $(document).scrollTop();
	$('div.pop-dailog').find('div.container').css('top',top+'px');
	$('div.pop-dailog').find('div.container').css('left',left+'px');
	$('div.pop-dailog').css('display','');
}
function closeUpImg(){
	$('div.pop-dailog').remove();
}

function upImg(imgId,inputId){
	$('#up_img').ajaxSubmit({
		success:function(html){
			html = $.trim(html);
		    if(html.indexOf('temp') > 0){
		    	if(imgId != ''){
		    		$('#'+imgId).attr('src',html);
		    	}
		    	if(inputId != ''){
		    		$('#'+inputId).val(html);
		    	}
   			    closeUpImg();
            }else{
            	alert('上传图片必须为jpg、gif、png,且小于1M!');
            }
		}
	});
}

function clearImg(obj){
	obj = $(obj).parent().prev('p');
	if($(obj).find('img')[0]){
		$(obj).find('img').attr('src','');
	}
	if($(obj).find('input')[0]){
		$(obj).find('input').val('');
	}
}
function deleteImg(obj){
	$(obj).parent().parent().remove();
}

function popDailog(title,html,height){
	$('div.pop-dailog').remove();
	var html='<div class="pop-dailog" style="display:none;height:'+$(document).height()+'px;">'
		   +'<div class="container">'
		   +'<div class="head">'
		   +title+'<div class="buttons"><b class="pop-close" onclick="closeUpImg();"></b></div>'
		   +'</div>'
		   +'<div class="pop-content">'
		   + html
		   +'</div>'
		   +'</div>'
		   +'</div>';
	$('body').append(html);
	var left = ($(document).width()-$('div.pop-dailog').find('div.container').width())/2;
	left = left>0?left:0;
	var top = ($(window).height() - height)/2;
	top = top>0?top:0;
	top += $(document).scrollTop();
	$('div.pop-dailog').find('div.container').css('top',top+'px');
	$('div.pop-dailog').find('div.container').css('left',left+'px');
	$('div.pop-dailog').css('display','');
}

